package com.ziyun.erp.web.modules.member.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ziyun.erp.modules.member.entity.UserScholarshipEntity;
import com.ziyun.erp.modules.member.service.UserScholarshipService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 奖励金记录表
 *
 * @author gaosheng
 * @email 
 * @date 2018-11-14 19:04:08
 */
@RestController
@RequestMapping("member/userscholarship")
public class UserScholarshipController {
    @Autowired
    private UserScholarshipService userScholarshipService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("member:userscholarship:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = userScholarshipService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{logId}")
    @RequiresPermissions("member:userscholarship:info")
    public R info(@PathVariable("logId") Integer logId){
        UserScholarshipEntity userScholarship = userScholarshipService.selectById(logId);

        return R.ok().put("userScholarship", userScholarship);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("member:userscholarship:save")
    public R save(@RequestBody UserScholarshipEntity userScholarship){
        userScholarshipService.insert(userScholarship);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("member:userscholarship:update")
    public R update(@RequestBody UserScholarshipEntity userScholarship){
        ValidatorUtils.validateEntity(userScholarship);
        userScholarshipService.updateAllColumnById(userScholarship);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("member:userscholarship:delete")
    public R delete(@RequestBody Integer[] logIds){
        userScholarshipService.deleteBatchIds(Arrays.asList(logIds));

        return R.ok();
    }

}
